/**
 * Created by aa on 2016/7/8.
 */
'use strict';
var Redux=require('redux');
var utils=require('../common/utils.js')
var cr=utils.cr;
var actions=require('../actions/news');

var reducers=Redux.combineReducers({
    list: cr([], {
        /*RECEIVE_NEWS_LIST:(state, action)=>{return action.data.tngou}*/
        [actions.RECEIVE_NEWS_LIST](state, action){return action.data.tngou}
    }),
    totalPage: cr(0, {
        /*RECEIVE_NEWS_LIST:(state, action)=>
        {
            return Math.ceil( action.data.total/actions.PAGE_SIZE)
        }*/
        [actions.RECEIVE_NEWS_LIST](state, action){ return Math.ceil( action.data.total/actions.PAGE_SIZE)}
    }),
    page: cr(1, {
      /*  RECEIVE_NEWS_LIST:(state, action)=>{return action.page}*/
        [actions.RECEIVE_NEWS_LIST](state, action){return action.page}
    }),
    keyword: cr('', {
        /*SET_KEYWORD:(state, action)=>{return action.value}*/
        [actions.SET_KEYWORD](state, action){return action.value}
    }),
    current: cr({}, {
       /* SET_CURRENT_NEWS:(state, action)=>{return action.news}*/
        [actions.SET_CURRENT_NEWS](state, action){return action.news}
    }),
    getbyid:cr({},{
       /* GET_SINGLE_NEWS:(state,action)=>{return action.data}*/
        [actions.GET_SINGLE_NEWS](state,action){return action.data}
    })
});
module.exports=reducers;
